home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / f2c95201 / src / libf77 / s_paus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-06  |  1.8 KB  |  98 lines

  1. #include "stdio.h"
  2. #include "f2c.h"
  3. #define PAUSESIG 15
  4.  
  5. #ifdef KR_headers
  6. #define Void /* void */
  7. #define Int /* int */
  8. #else
  9. #define Void void
  10. #define Int int
  11. #undef abs
  12. #undef min
  13. #undef max
  14. #include "stdlib.h"
  15. #include "signal.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /* to avoid conflict with djgppstd.h.
  20.  * 12/15/94 by K&R (Kuroki & Raraki)
  21.  */
  22. #ifndef __GO32__
  23. extern int getpid(void), isatty(int), pause(void);
  24. #else  /* __GO32__ */
  25. extern int getpid(void), isatty(int);
  26. extern void volatile pause(void);
  27. #endif /* __GO32__ */
  28. #endif
  29. /* end of Patch */
  30.  
  31. extern VOID f_exit(Void);
  32.  
  33.  static VOID
  34. waitpause(Int n)
  35. {    n = n; /* shut up compiler warning */
  36.     return;
  37.     }
  38.  
  39.  static VOID
  40. #ifdef KR_headers
  41. s_1paus(fin) FILE *fin;
  42. #else
  43. s_1paus(FILE *fin)
  44. #endif
  45. {
  46.     fprintf(stderr,
  47.     "To resume execution, type go.  Other input will terminate the job.\n");
  48.     fflush(stderr);
  49.     if( getc(fin)!='g' || getc(fin)!='o' || getc(fin)!='\n' ) {
  50.         fprintf(stderr, "STOP\n");
  51. #ifdef NO_ONEXIT
  52.         f_exit();
  53. #endif
  54.         exit(0);
  55.         }
  56.     }
  57.  
  58.  int
  59. #ifdef KR_headers
  60. s_paus(s, n) char *s; ftnlen n;
  61. #else
  62. s_paus(char *s, ftnlen n)
  63. #endif
  64. {
  65.     fprintf(stderr, "PAUSE ");
  66.     if(n > 0)
  67.         fprintf(stderr, " %.*s", (int)n, s);
  68.     fprintf(stderr, " statement executed\n");
  69.     if( isatty(fileno(stdin)) )
  70.         s_1paus(stdin);
  71.     else {
  72. #ifdef MSDOS
  73.         FILE *fin;
  74.         fin = fopen("con", "r");
  75.         if (!fin) {
  76.             fprintf(stderr, "s_paus: can't open con!\n");
  77.             fflush(stderr);
  78.             exit(1);
  79.             }
  80.         s_1paus(fin);
  81.         fclose(fin);
  82. #else
  83.         fprintf(stderr,
  84.         "To resume execution, execute a   kill -%d %d   command\n",
  85.             PAUSESIG, getpid() );
  86.         signal(PAUSESIG, waitpause);
  87.         fflush(stderr);
  88.         pause();
  89. #endif
  90.         }
  91.     fprintf(stderr, "Execution resumes after PAUSE.\n");
  92.     fflush(stderr);
  93.     return 0; /* NOT REACHED */
  94. #ifdef __cplusplus
  95.     }
  96. #endif
  97. }
  98.